package com.relax.no_xml.aop;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;

import java.util.Arrays;


@Aspect
public class LogAspects {

	@Pointcut("execution(public ** com.relax.no_xml.aop.AopService.*(..))")
	public void pointCut() {
	}


	@Before("pointCut()")
	public void logStart(JoinPoint joinPoint) {
		Object[] args = joinPoint.getArgs();
		System.out.println("aop  before invoke, method param is {" + Arrays.asList(args) + "}");
	}

	@After("com.relax.no_xml.aop.LogAspects.pointCut()")
	public void logEnd(JoinPoint joinPoint) {
		System.out.println("aop  after invoke, method param is" + joinPoint.getSignature().getName() + "");
	}

	@AfterReturning(value = "pointCut()", returning = "result")
	public void logReturn(JoinPoint joinPoint, Object result) {
		System.out.println("aop  before return, method param is:" + joinPoint.getSignature().getName() + "result{" + result + "}");
	}

	@AfterThrowing(value = "pointCut()", throwing = "exception")
	public void logException(JoinPoint joinPoint, Exception exception) {
		System.out.println("aop  exception invoke, method param is:" + joinPoint.getSignature().getName() + "AfterThrowing :" + exception + "}");
	}

}
